package edu.kit.los.lookup;

import java.util.LinkedList;
import java.util.List;

import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.esxx.js.protocol.GAEConnectionManager;

import upcoming.client.EventSearchCriteria;
import edu.kit.los.event.StandartEvent;

/**
 * @author felix
 * Führt mit Hilfe der Upcoming-Java Api einen Lookups bei Upcoming durch
 */
public class UpcomingLookup extends Lookup{

	
	public List<StandartEvent> lookup(String query, int limit) {
		HttpParams httpParams = new BasicHttpParams();
		
		ClientConnectionManager connectionManager = new GAEConnectionManager();
		org.apache.http.client.HttpClient httpClient = new DefaultHttpClient(connectionManager, httpParams);
		upcoming.client.Client client = new upcoming.client.Client(httpClient, "6f0d8fce85");
		List<upcoming.client.Event> upcevent = new LinkedList<upcoming.client.Event>();
		EventSearchCriteria criteria = new EventSearchCriteria();
		//criteria.set
		upcevent = client.findEvents(query);
		List<StandartEvent> events = new LinkedList<StandartEvent>();
		
		for (upcoming.client.Event ev : upcevent){
			StandartEvent endev = new StandartEvent(ev);
			events.add(endev);
		}
		return events;
				
	}

}
